import { onMounted } from '@vue/runtime-core';
export default function (options: string, width: number = 100, height: number = 60): Promise<{BaseUrl: string}> {
  return new Promise(resolve => {
    onMounted(() => {
      let imgDom = document.querySelector(options) as HTMLImageElement;
      imgDom.onload = function () {
        let canvas = document.createElement('canvas');
        let ctx = <CanvasRenderingContext2D>canvas.getContext('2d');
        ctx.drawImage(imgDom, 0, 0, width, height);
        resolve({
          BaseUrl: canvas.toDataURL('image/png')
        })
      };
    })
  });
}